From 84d4e00ad10a461bfb2b7980b96d809161dbf9b0 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Fri, 1 Jun 2018 09:26:51 -0600 Subject: [PATCH] add make targets to use clang-tidy. --- GPSBabel.pro | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/GPSBabel.pro b/GPSBabel.pro index 10ef22de1..4a5cb2dfc 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -203,3 +203,23 @@ macx|linux{ check.depends = $(TARGET) QMAKE_EXTRA_TARGETS += check } + +# build the compilation data base used by clang tools including clang-tidy. +# I am not sure how to do this on non-linux platforms, bear is linux specific. +linux{ + compile_command_database.target = compile_commands.json + compile_command_database.commands = make clean; bear make + QMAKE_EXTRA_TARGETS += compile_command_database +} + +# run clang-tidy +# example usage: +# make clang-tidy RUN_CLANG_TIDY_FLAGS="-header-filter=.*\\\.h -checks=-*,modernize-use-nullptr -fix" +# It seems to be better to use run-clang-tidy with the compilation database as opposed to +# running clang-tidy directly and listing the +# compilation options on the clang-tidy line after --. +# An example is modernize-use-override which inserts repeadted overrides when run directly, +# but works as expected when run with run-clang-tidy. +clang-tidy.commands = run-clang-tidy.py $(RUN_CLANG_TIDY_FLAGS) +clang-tidy.depends = compile_commands.json +QMAKE_EXTRA_TARGETS += clang-tidy -- 2.30.2